#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int dp[1 << 18][20][20];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) {
    string s;
    cin >> s;
    bitset<18> b{s};
    int x = b.to_ulong();
    dp[x][0][0]++;
  }
  int mask = (1 << m) - 1;
  rep(j, 1, m) {
    int bit = 1 << (j - 1);
    rep(x, 0, mask) {
      rep(k, 0, m) {
        dp[x][j][k] = dp[x][j - 1][k];
        if (k >= 1) dp[x][j][k] += dp[x ^ bit][j - 1][k - 1];
      }
    }
  }
  int ans = n * m;
  rep(x, 0, mask) {
    int now = 0;
    rep(k, 0, m) { now += dp[x][m][k] * min(k, m - k); }
    ans = min(ans, now);
  }
  cout << ans;
  return 0;
}